function L = OutLevel(Sig,tc,net,ParamWN,FoldOpera,FileOut)
% OutLevel - Output lever for CNN operation
%
%   L = OutLevel(Sig,tc,net,ParamWN,FoldOpera)
% 
% Computes the output level L at the time tc (espressed as a serial date 
% number) by means of the CNN net with the parameter struct file ParamWN
% and placing the output scalogram file in the subfolder 'Last' of the 
% folder FoldOpera with filename 
%   fullfile(FoldOpera,'Last',[FileOut '_' datestr(tc) '.jpg'])
%
% See also PluVelOpera

% G. Teza, 2020

ParamWNOpera = ParamWN;

ParamWNOpera.DateIn  = tc-ParamWN.Na;
ParamWNOpera.DateFin = tc+ParamWN.Nb; 
FoldLast = fullfile(FoldOpera,Last,FileOut);
if exist(FoldLast,'dir') ~= 7
    mkdir(FoldLast);
else
    movefile(FoldLast,FoldOpera);  % In this way, FoldLast is an empty folder
end
ParamWNOpera.ComPart = FoldLast;

Vmh = ParamWNOpera.Vmh;

% Output scalogram generation (note the struct object-like variable):
PluVelScalogram(Sig,ParamWNOpera);

IMDS = imageDatastore(FoldLast);
[L,~] = classify(net,IMDS,'MiniBatchSize',ParamWN.MiniBatchSize);